Skip to content

fix(scenarios): travel_expense filing checks per-type amounts via aggregate post-states and relation paths; records stamp the card sha256 and summaries refuse mixed cards - #35044

Merged
objectstack-fleet[bot] merged 7 commits into
mainfrom
claude/issue-35025-per-type-amounts
Nov 18, 2026
Merged

objectstack-fleet[bot] merged 7 commits into
mainfrom
claude/issue-35025-per-type-amounts

Conversation

@objectstack-fleet

@objectstack-fleet objectstack-fleet Bot commented Nov 18, 2026 •

Copy link
Copy Markdown
Contributor

Requested by Yibo Wang · project thread
Fixes #35025
Clause-②: yes (widening) — the run record gains a top-level card: { id, sha256 } and its scorecard a cardStamp; a card's post-state gains the optional sum / each members and relation-path where keys; new exports CardStamp, cardStampOf, cardStampText, relationObjects, DeclaredLookups; LoadedScenario gains fileSha256; cli.ts exports loadedCardStamp; summary gains a card dimension. Every card and record that loaded, graded or summed before still does.
Metadata-protocol: none

This PR delivers both halves of #35025: the card and grader change, and a card stamp on the record and the scorecard, which tells a round graded before a card change from one graded after it. Round 2 merged origin/main (#35023 landed as 339c2f4) with a plain merge, which applied with no conflicts, and added the stamp on top.

维护者速读

  • 改了什么:差旅报销场景卡 file_and_submit_from_text 不再要求明细行必须是「酒店 1 行×2 晚、餐补 1 行×3 天」。现在检查的是:TR-0121 这张新报销单下,酒店合计 860,餐补合计 345,且没有任何一行超标。报销单本身的检查(报销人、已提交、总额 1205、审计人)不变。为此评分器新增两样东西:聚合式状态检查(sum / each),以及 where 里的关联路径(如 claim.trip)。
  • 为什么改:按晚、按天逐行填写(数量都是 1,总额同样是 1205)同样忠实于用户的话,以前却被判失败,压低了问数日轮的 operations 指标。
  • 风险与回滚:只影响评测打分(@objectstack/scenarios),不影响运行时。其它场景卡不受影响。本卡这一项在改动前后的轮次之间不可直接对比,所以每条运行记录现在都带上卡片文件的 sha256,记分卡多打一行 card: travel_expense (sha256 …)。summary 遇到卡片哈希不同的记录会拒绝合并,并写明两个哈希各自来自哪些记录。回滚即还原本 PR。
  • 先看:packages/qa/scenarios/src/score/scenario-operation-grade.ts(aggregateChecks)、packages/qa/scenarios/src/runner/observe.ts(readPath / relationObjects)、packages/qa/scenarios/src/runner/summary.ts(card 维度与拒绝行)。
  • 两分钟验证:pnpm --filter @objectstack/scenarios exec vitest run --maxWorkers=2 test/travel-expense.test.ts,预期 10 个测试全过,其中两种填法都通过,填错的三种情况失败。
  • 需要你做的:无,席位落地。

What changes

  • Card (docs/qa/scenarios/travel_expense.json, operation file_and_submit_from_text). The two claim-line entries pinned {expense_type, quantity: 2|3, unit_amount} and read one row each. They are replaced by three aggregate entries, all scoped to the new claim for trip t121 through claim.trip:

    • sum: {amount: 860} over the hotel lines;
    • sum: {amount: 345} over the meals lines;
    • each: {over_standard: false} over every line of the claim.

    The claim entry (claimant e02, status submitted, total_amount 1205) and auditActor: employee are unchanged.

  • Grader (score/scenario-operation-grade.ts). The grader could not express a sum or a multi-row match before: a where had to match exactly one row (->one-row), and where keys were the object's own fields only. An applied state entry can now be an aggregate over every row its where matches:

    • sum: each field's total must equal the declared number (state:LABEL.sum(amount), within a millionth). A row that reads no number fails it.
    • each: every row must hold the value (state:LABEL.each(field)), compared the way values compares it.
    • At least one row must match. No match fails ->rows, never a vacuous pass.
  • Schema (schema.ts PostStateSchema):

    • sum and each are optional.
    • An entry carries exactly one of values, absent or an aggregate.
    • An aggregate names its rows by where, never by id.
    • An aggregate lists at least one field.
    • A where key may be a dotted relation path (FieldPathSchema).
  • Loader (loader.ts):

    • each where key goes through the same relation-path check that persona scopes and truth filters use (checkPath, against expect.lookups);
    • each sum and each field must be one the seed carries;
    • a summed field that holds a non-number on any seed row is refused.
  • Runner (runner/observe.ts, runner/orchestrate.ts). postStateRows resolves a relation path through the card's lookups and the rows read after the turn. relationObjects names the objects a path hops to, and the runner now reads them beside the post-states' own objects. touchedRowId and observeOperation take the lookups too.

  • Docs: the card format in docs/qa/scenarios/README.md, and the grader line in packages/qa/scenarios/README.md.

  • Card stamp (runner/scorecard.ts, runner/cli.ts, runner/summary.ts):

    • CardStamp { id, sha256 } and cardStampOf. The sha256 is taken over the card file's bytes as the runner loaded them, before the run moved its dates or prefixed its names.
    • The loader hashes the very bytes it parsed (LoadedScenario.fileSha256, new). cli.ts stamps each run from that through loadedCardStamp, never by reading the file again after the run. A card edited during its run keeps its load-time hash, and a card moved or deleted meanwhile still gets its record. This follows the supplied-template path, which also hashes the bytes it read once.
    • runRecord writes it at the record's top level (card), and cardScorecard carries it as cardStamp.
    • renderScorecard prints card: travel_expense (sha256 FIRST12) under the packages line.
    • A replay stamps the card as it is now, so a regrade on a changed card shows the new hash.
    • summary adds card to TABLE_DIMENSIONS. A table whose runs graded two card files is refused, with the line the runs differ in card: `card: ID (sha256 A)` (files…) vs `card: ID (sha256 B)` (files…), naming each hash and the records holding it. A stamped record next to one written before the stamp reads card: not recorded and is refused the same way. Unstamped records keep summing with each other, and their dimensions line is unchanged.
  • Changeset: patch on @objectstack/scenarios (Metadata-protocol none), with both declaration lines.

Tests

All readings at head b2d22c5f.

  • test/travel-expense.test.ts, a new top-level describe. It runs the real card through namespacedScenario, observeOperation and gradeCardOperation, over the full seed, whose other claims carry hotel and meals lines of their own:
    • it pins the declared outcome, and relationObjects = [demotravel_expense_claim];
    • the quantity-2/3 rows (the claim and lines the area's iteration-2 run read back) pass, and the per-night/per-day rows (the lines the five-rep agent sent on 18.5.0) pass. A second new claim on trip t124, with an over-standard hotel line at 430, sits beside them and is kept out;
    • the recorded run's rows fail on status alone;
    • wrong filings fail: one hotel night short (hotel sum and claim total), an extra over-standard line on the claim (each(over_standard)), and a claim with no lines (three ->rows);
    • without the card's lookups no line resolves, so the operation fails. It never sums every hotel line.
  • test/score/scenario-operation-grade.test.ts, a new describe for the aggregate checks: both line shapes, a wrong total, an over-standard line, a non-number cell, zero rows, decimal sums, and an unobserved aggregate.
  • test/runner/summary.test.ts, a new top-level describe for the card dimension. Two hashes refuse the table, and the refusal line names each hash with its records (a1.json, a2.json vs b.json); summaryMain exits 1. A stamped record next to an unstamped one is refused. One hash sums, and the dimensions line names it. Unstamped records print no card:.
  • test/runner/orchestrate.test.ts, a new top-level describe:
    • runRecord stamps card at the top level and on the scorecard, and the scorecard prints the line;
    • a one-character change to the card moves the hash;
    • a record without a stamp has no card key and no line;
    • a copy of the card is loaded, then edited between load and record write: the record is written and stamped with the load-time hash, not the edited file's;
    • a copy of the card is loaded, then deleted between load and record write: the record is still written, stamped with the load-time hash.
  • test/refusals.test.ts: seven new refusal cases (an aggregate by id, values plus an aggregate, an empty each, a sum over a text field, a sum over a missing field, a path through no declared lookup, a path ending on a missing field). Plus one clean-load control: account.name path, an each, and a sum over employees.
Package suite, typecheck, ablation
  • pnpm --filter @objectstack/scenarios build && … typecheck && … test at b2d22c5f: VERDICT command-exit 0, Test Files 39 passed (39), Tests 1128 passed (1128).
  • tsc --noEmit -p tsconfig.json --listFiles includes the edited test files.
  • Ablation. Each leg went through scripts/ablation-replace.mjs: the anchor hit went from 1 to 0, and the restore was confirmed by a blob equal to HEAD and an empty git diff HEAD. The tests import src/, so there is no dist leg.
    • In gradeOperation, checks.push(...aggregateChecks(at, s, rows)); replaced by void aggregateChecks;: Tests 6 failed | 52 passed (58) across travel-expense and scenario-operation-grade.
    • In observe.ts matches, the relation-path read replaced by undefined: Tests 3 failed | 7 passed (10) in travel-expense (both pass cases, the recorded-run case and the wrong-filing case).
    • In summary.ts, 'card' dropped from TABLE_DIMENSIONS: Tests 3 failed | 24 passed (27) in summary.
    • In scorecard.ts, the cardStampText line deleted from renderScorecard: Tests 1 failed | 143 passed (144) in orchestrate.
    • In cli.ts, loadedCardStamp put back to re-reading the file after the run (suppliedTemplateOf(loaded.file).sha256): Tests 2 failed | 2 passed | 142 skipped (146) under -t 'card stamp'. The edited-card pin fails on the hash, and the deleted-card pin fails with ENOENT.

Acceptance notes

  • Card identity before this PR. No record or scorecard field identified the card: there was no card hash, caseHash or revision, and env.framework is only the checkout commit. The stamp is new in this PR. Records written before it read card: not recorded in summary, and are never summed with stamped ones.
  • Replay fidelity: a finding outside this card's scope. The replay of the iteration-2 recording (below) read this operation as NOT MEASURED, not graded. The recorded turn creates the claim through run_action (demotravel_file_expense_claim), which answers { ok, action, objectName, result: { id } }. RecordedDriver's createdIdOf (runner/driver.ts) reads only a top-level id. So the new claim's id is never mapped, and the next run_action (demotravel_submit_claim) is re-sent with the recorded recordId. The app answers RECORD_NOT_FOUND, not the recorded HOOK_ABORTED. This is reported to the seat for filing, not fixed here.

Verification

Regrade of the iteration-2 recording (travel_expense, ask, workspace)

Command: run-scenarios --only travel_expense --modes ask --template …/build/travel_expense/template.json --ask-repeats 5 --packages workspace --driver recorded:…/iter2/ask.rec.json, written to a scratch out dir (round 1, at 6513b37c; packages: workspace @ 6513b37c). Round 2 did not repeat it: the card-stamp commits change no grade.

  • Before (the round's own record, packages: workspace @ 99bd2203): file_and_submit_from_text FAIL on state:demotravel_expense_claim[trip="t121"].status alone (read "draft", declared "submitted"). The two quantity-shaped line entries pass. Run-operations 2/3 · 3 not measured · 2 started from restored rows.
  • After (replay at 6513b37c): the operation is NOT MEASURED: the replay is not faithful: … run_action was refused HOOK_ABORTED in the recorded run and refused RECORD_NOT_FOUND on replay (see Acceptance notes). Run-operations 2/2 · 4 not measured · 2 started from restored rows. Seed 173/757, Run-问数 25/25 · 40 not measured and Run · datasets 25/25 are the same as the recorded round.
  • So I also graded the record's own observed rows directly with the grader at 6513b37c: the record's claim row and its two lines, over the namespaced seed, through observeOperation and gradeCardOperation. Result: FAIL on status alone. sum(amount) reads 860 = 860 over 1 row(s) for hotel and 345 = 345 over 1 row(s) for meals, and each(over_standard) reads 2 of 2 row(s) read false. Claimant, total and audit actor pass. One limit: the record keeps only the rows the old where matched, so a third line on that claim would not show here.
Local gates
  • node scripts/pm/dispatch-gates.mjs --commands at b2d22c5f derived 70 commands. 68 exited 0. Two exited 3 (PREREQUISITE NOT MET), so they are NOT MEASURED:

    • node scripts/check-plugin-teardown-shape.mjs --self-test: its fixture is pinned to a commit outside this shallow clone, and it tests the checker itself;
    • pnpm check:dual-build-cjs-loads: it needs the whole workspace dist/ after the merge (CI builds it).

    --ran reconciliation: 70 derived, 68 run, 2 NOT-MEASURED, 0 UNRUN.

  • node scripts/pm/overlap-check.mjs at b2d22c5f: VERDICT clean exit 0. It merges cleanly with origin/main a3e216e, and no open PR shares a file.

  • node scripts/check-nul-bytes.mjs: exit 0.

  • CI families are left to this PR's check-runs.


Generated by Claude Code

…_submit_from_text

Co-Authored-By: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01WGufziH9rnXEpD9ne7yFhD
…ther line shape

Add aggregate post-states (sum / each) and relation paths in a post-state
where, with loader validation, tests, README lines and a changeset.

Co-Authored-By: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01WGufziH9rnXEpD9ne7yFhD
@github-actions github-actions Bot added size/m documentation Improvements or additions to documentation tests tooling Fix lands in tooling, not a product package — enters pm:queue only with Unblocks: or a named surface labels Nov 18, 2026
@github-actions

github-actions Bot commented Nov 18, 2026 •

Copy link
Copy Markdown
Contributor

📓 Docs Drift Check

33 anchor(s) derived from 1 changed package(s); no hand-written page names any of them. ⚠️ 1 changed file(s) yielded no anchor (packages/qa/scenarios/README.md), so the pages documenting them are NOT COVERED by this run — this is not a clean bill of health for those files.

What this run could not see
  • 1 changed file(s) yielded no anchor (packages/qa/scenarios/README.md) — pages documenting those are invisible to this run
  • 8 name(s) were too generic to anchor anything (single lowercase words)
  • the SDK route bridge reached 65 of 247 client-bound route-ledger rows — the other 182 have no registrar path: tail to select them, so pages documenting THEIR client methods cannot appear above, on this or any run. Of those 182: 0 are remediable by widening that discovery convention (an in-repo file declares the path; the convention did not scan it); 59 are structural — on a ledger where NOT ONE row is declared in-repo, so no discovery change reaches them at any price; 123 are undecided (no in-repo declaration, on a ledger that has other in-repo registrars — absence and an unreadable spelling are not distinguishable here). The rows themselves: node scripts/docs-audit/affected-docs.mjs --bridge-coverage
  • a page that states a rule by its inputs shares no identifier with the emitter that implements the rule, so an emitter-only diff cannot list it — not on this run and not on any run. Measured on fix(driver-sql): emit varchar(maxLength) for a text field a declared index keys on #11430: content/docs/protocol/objectql/types.mdx documents the text-family column mapping by the ObjectQL type names it maps FROM (text / textarea / html) while the diff changed createColumn; it went unlisted, and it was the page that diff falsified, in four places. No shared token exists to detect this on, so a rule your change carries has to be re-read by hand in the pages that restate it.
  • a key NAME is not a key, so the hand re-read the line above prescribes can land on the wrong schema. The same spelling is authorable on one governed type and a [REMOVED] tombstone on another for each of active, aria, joins, objects, template, tools and version (censused on [finding] tools is a key on BOTH AgentSchema (tombstoned, dead) and SkillSchema (live, cloud-attested), so a name-based search attributes skill examples to the agent key — it produced a false stop-the-line alarm on PR #19059 #19093 over the liveness ledger's governed types, top-level keys); nothing in a search result distinguishes the two, so a grep hit on a LIVE example reads as evidence about the DEAD key. Measured on fix(spec): the agent.tools liveness row says dead — it claimed live on a key the schema tombstoned #19059: content/docs/ai/agents.mdx was reported as contradicting the agent.tools tombstone over its tools: example at :161, which is inside the defineSkill({ block opened at :155 — the page was already correct. Settle ownership by PARSING the value against both schemas, never by the name: that literal PASSES SkillSchema, and as an AgentSchema it FAILS at tools with the tombstone prescription. ⛔ These names are not the whole class — a key retired through a .strict() guidance map leaves no tombstone in the walked shape and none of them here (tool.category, live as AIToolDefinition.category).

Coarse fallback — 1 page(s) merely mention a changed package (the pre-#9192 predicate, kept for the deliberately-wide backstop): node scripts/docs-audit/affected-docs.mjs --json b85dff0f4350f4846b03c31b328fc5a8f782d1c9 → packageMentionDocs.

Which tree this was computed on

This run read content/docs from 97c06b6df7439abf9fa4e898e6a3a63526e64aeb — the merge of head 236748846a49323b9223904672f1a0c049a7cb32 into base b85dff0f4350f4846b03c31b328fc5a8f782d1c9, which is what actions/checkout gives a pull_request run. Not the PR head.

A worktree cut from an older main holds a different content/docs, so re-deriving there can legitimately return a different list — that is a different tree, not a wrong row. To answer on the same tree:

# while this PR is open — GitHub drops the merge commit once it closes
git fetch origin 97c06b6df7439abf9fa4e898e6a3a63526e64aeb && git checkout 97c06b6df7439abf9fa4e898e6a3a63526e64aeb
# afterwards, rebuild it from the two parents, which stay fetchable
git fetch origin b85dff0f4350f4846b03c31b328fc5a8f782d1c9 236748846a49323b9223904672f1a0c049a7cb32 && git checkout -B drift-repro b85dff0f4350f4846b03c31b328fc5a8f782d1c9 && git merge --no-ff 236748846a49323b9223904672f1a0c049a7cb32

node scripts/docs-audit/affected-docs.mjs --json b85dff0f4350f4846b03c31b328fc5a8f782d1c9

⚠️ That checkout carried uncommitted changes, so the commit above does not fully identify what was read.

@github-actions github-actions Bot added size/l and removed size/m labels Nov 18, 2026
…se-② yes (widening)

Co-Authored-By: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01WGufziH9rnXEpD9ne7yFhD
@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack#3 · os-support-ai · session_01WGufzfWpJ96QY9T7d8DvFg

L1: ACCEPT · 2026-11-18T01:45Z

Head-sha: c8ab4e4
Reviewer: seat 3 L1-c (epic #34659)

席位核对

  • Card scenarios travel_expense: file_and_submit_from_text pins the claim lines' quantity shape (2 x 430, 3 x 115) — check the per-type amounts instead, so per-unit lines also pass #35025, Fixes #35025 in the body. 17 files, +562/−37, all under packages/qa/scenarios/**, docs/qa/scenarios/** and one changeset. check-governed-merges --pr 35044: NOT governed (0 of 17 paths), under the size threshold.
  • CI on c8ab4e4: 37 success, 18 skipped, nothing red or pending.
  • Round 2 = the round-1 fix (6513b37) + a plain merge of main eb7b09d (a856f36) + the card stamp (5a802de) + docs (c8ab4e4). No earlier L1 on this PR, so this is a full read of the whole diff against main.
  • Changeset: @objectstack/scenarios patch, Metadata-protocol: none, so patch is the right level. Clause-②: yes (widening) lists the new record/scorecard members (card, cardStamp), the optional post-state members (sum, each, relation-path where keys), the new exports (CardStamp, cardStampOf, cardStampText, relationObjects, DeclaredLookups) and the summary dimension. I checked that list against the diff and it is complete. Every widening is additive: old cards still parse (values / absent unchanged), old records still sum with each other (card: not recorded).

What I checked

  • Schema (schema.ts): an entry carries exactly one of values, absent or an aggregate. An aggregate is named by where and never by id. sum / each must name at least one field. where keys widen to FieldPathSchema, and values / sum / each keys stay MachineNameSchema, which is right because they are the object's own fields.
  • Loader (loader.ts): where keys go through checkPath, which already resolves relation paths through declared lookups. values / sum / each fields go through checkField. A summed field that holds a non-number on any seed row is refused.
  • Grading (aggregateChecks): no matched row gives one failing ->rows check, so a sum of nothing never passes as 0 and a vacuous "every row" never passes. A row reading no number fails .sum(field) with the offending cells named. The sum tolerance is 1e-6 and each compares with the same same() as values. The aggregate branch returns before the "exactly one row" duplicate check, which is correct: many rows is what an aggregate reads.
  • Relation paths (observe.ts): relationObjects walks every hop but the last through expect.lookups, and orchestrate reads those objects after the turn beside the post-states' own. readPath follows string ids only. An unresolved hop reads undefined, which matches only a declared null. Path keys skip the card's-today leniency, which is right because that leniency is about a field stamped on this row. touchedRowId gets the lookups too, so the audit-actor read on a where-named row still resolves.
  • The card change: claim.trip → claim_line.claim (→ expense_claim) → .trip. All three lookups are declared in expect.lookups. No seeded expense_claim sits on t121 (the seed has only the trip row), so the sums read only the lines of the claim the turn created. A duplicate claim for t121 would double the sums and fail, which is the right verdict. The claim-level entry (claimant e02, submitted, total_amount 1205, auditActor) is unchanged.
  • The card stamp: cardStampOf hashes the card file's bytes. runRecord puts it at the top level and on the scorecard. The scorecard prints card: <id> (sha256 <12>) under the packages line. summary adds card to TABLE_DIMENSIONS. Two hashes, or a stamped record next to an unstamped one, refuse the table. Unstamped records keep their old dimensions line.
  • Tests cover:
    • quantity-2/3 lines versus per-night/per-day lines;
    • the seed's other lines and another new claim left out;
    • the recorded run still failing on status alone;
    • a short night, an over-standard line and an empty claim all failing;
    • missing lookups failing rather than summing every hotel line;
    • decimals;
    • no row matched;
    • the three summary refusal and accept cases;
    • the loader control.

Must-fix

None.

Should-fix

None.

Notes

  • N1: cli.ts takes the stamp with readFileSync(loaded.file) after runCard returns. So it hashes the file as it is when the record is written, not the bytes the run loaded, which is what the CardStamp doc comment and the changeset say. In practice it only differs if the card is edited during a run. Either read the bytes once at load time and carry them, or reword the doc to "as the file reads when the record is written". Not blocking.
  • N2: c4a0c6d has a wip(...) subject. The squash on landing covers it. Keep the squash title as the fix line.

Next

Clause-② is yes, so this goes to the seat's L2. After that it is an ordinary queue landing (not governed). If anything is pushed after c8ab4e4, a delta read is owed.

@objectstack-fleet objectstack-fleet Bot changed the title fix(scenarios): travel_expense file_and_submit_from_text checks per-type amounts, so per-unit lines pass fix(scenarios): travel_expense filing checks per-type amounts via aggregate post-states and relation paths; records stamp the card sha256 and summaries refuse mixed cards Nov 18, 2026
@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack#3 · os-support-ai · session_01WGufzgh1zkZzDXL36ckWAG

Contract-review-claim: session_01WGufzgh1zkZzDXL36ckWAG · head c8ab4e48ee09164f7d8d2d712368e085bdb5db30 · 2026-11-18T01:47Z

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack#3 · os-support-ai · session_01WGufzgh1zkZzDXL36ckWAG

Contract review

Served-tier: TIER_DEFAULT
Head-sha: c8ab4e48ee09164f7d8d2d712368e085bdb5db30
Local-runs: none

Face: declaration (Clause-②: yes (widening) on the PR body and changeset; 0 of 17 paths published-schema or governed). Inputs read: card #35025 body and all 4 comments (claim 6964093785, round-1 report 6964789623, claim amendment 6966396612, round-2 report 6966433661); PR #35044 body, 17-file list, net diff eb7b09d4..c8ab4e48; PR comments (docs-drift 6964796696, L1 ACCEPT 6966499629, this review's claim 6966524337); check-runs on the head.

Check-runs on c8ab4e48: 59 runs, every one completed; 0 failure, cancelled or timed-out. Success includes Lint & Repo Gates (all 8 scoped legs), TypeScript Type Check (4 legs), Test Core (planned shards 1-7 and the aggregate), Build Core, Test UI, Live E2E UI, Dogfood Regression Gate, Governed Surface Queue Guard, Check Changeset (all 3 runs; the last finished 01:49:18Z), PR-body guards (3 runs), Check Documentation Links. The rest are skipped by path filter.

① Derived judgments

Each accept-set or public-surface change the diff implies (./runner re-exports observe, scorecard and summary; . re-exports schema and loader; the card library ships as package data):

  1. PostStateSchema gains optional sum and each. Right, widening. The exactly-one refine now counts values, absent and an aggregate. For a card without an aggregate it is the old values xor absent rule, so every old card still parses. The new refusals (an aggregate by id, an empty sum/each) only reach the new members.
  2. where keys go from MachineNameSchema to FieldPathSchema. Right, widening. The FieldPathSchema regex accepts every machine name, since a path with no dot is a machine name. In the loader, checkPath on a dotless key falls straight through to checkField, the check where keys had before (loader.ts 662-679), so no old card is newly refused.
  3. The loader refuses a sum field that holds a non-number on a seed row. Right. It applies only to the new member.
  4. Grader aggregateChecks (scenario-operation-grade.ts). Right. Zero matched rows fail ->rows once, so a sum or each over nothing is never vacuously met. A cell that is not a number fails .sum(field) and names the offending cells. The tolerance is 1e-6. each compares with the same same() as values. The branch returns before the one-row duplicate check, which is the point of an aggregate. Old entries never take the branch.
  5. Relation paths in observe.ts (relationObjects, readPath, matches). Right. Every hop but the last goes through expect.lookups, a hop reads only a string id, and an unresolved hop reads undefined, which matches nothing but a declared null. Path keys skip the card's-today leniency, which is about a field stamped on the row itself. postStateRows, touchedRowId and ObserveInput each gain one optional trailing member that defaults to no lookups, so existing callers are unchanged.
  6. The card change (travel_expense.json, file_and_submit_from_text). Right, and it is what scenarios travel_expense: file_and_submit_from_text pins the claim lines' quantity shape (2 x 430, 3 x 115) — check the per-type amounts instead, so per-unit lines also pass #35025 asks for. Hotel sum(amount)=860 and meals sum(amount)=345 are scoped through claim.trip = t121, plus each(over_standard)=false over every line of that claim. The hop chain claim_line.claim to expense_claim, then .trip, is declared in the card's expect.lookups (read on the head). The claim-level entry and auditActor are unchanged. This loosens the line-shape pin by design: unit amount and quantity are no longer checked, and the per-type totals are. A duplicate claim on t121 doubles the sums and fails, which is the right verdict.
  7. Record top-level card: {id, sha256}, scorecard cardStamp, and the scorecard line. Right as a shape, widening. All are optional and absent when no stamp is passed (runRecord, cardScorecard). No existing record or scorecard field is removed, renamed or made required. The provenance of the hash is wrong in one window, see S1 in ③.
  8. summary gains a card dimension (TABLE_DIMENSIONS). Right: it does not narrow stored records. A record without card reads card: not recorded. Every pre-change record reads that same value, so stored records keep summing with each other, and their dimensions line is unchanged because NO_CARD_STAMP is filtered out (summary.ts 495). The only newly refused table mixes a pre-change record with a stamped one. A stamped record could not exist before this change, so no input set that summed before is refused now. The refusal names both sides and their files, as claimed: the generic dimension refusal (summary.ts 437-441) prints the runs differ in card: `card: ID (sha256 FIRST12)` (files) vs `card: ID (sha256 FIRST12)` (files). It is pinned verbatim in summary.test.ts, both for two hashes (a1, a2 vs b, exit 1) and for stamped vs not recorded. The "hash" it names is the 12-hex prefix; the full sha256 stays in the record (see n1).
  9. New exports CardStamp, cardStampOf, cardStampText, relationObjects, DeclaredLookups. Additive, and the Clause-② line lists all five. The list is complete against the diff.

② Semver level

  • Changeset: '@objectstack/scenarios': patch, Metadata-protocol: none, Clause-②: yes (widening). Right. By AGENTS.md (Post-Task Checklist step 3), the level follows the Metadata-protocol kind alone, and none takes patch. none is right because the scenario-card format is a devx instrument, not platform metadata (the package description says "packages/spec carries no obligation for this format"), so no metadata author's accept-set moves. The (widening) arm is right by ① 1-9. Check Changeset is green on all three runs.
  • Clause-②: the yes (widening) line is present at line start in both the PR body and the changeset, and matches the claim amendment 6966396612. The round-1 claim's Clause-②: no was superseded by that amendment when the stamp was added.
  • One sentence in the changeset is not true in every case: "the sha256 of the card file's bytes as the runner loaded them". That changeset ships as CHANGELOG text, so it is folded into S1 below.

③ Boundary flags

S1 (should-fix): the card stamp hashes the file at record-write time, not the bytes the run loaded. This is L1 N1, graded up from a note.

  • What the code does: cli.ts 485 calls cardStampOf(loaded.card.id, readFileSync(loaded.file)) after await runCard(...) returns. The loader read and parsed the card at startup (loader.ts 208, loadOne), before the per-card loop.
  • What the contract says: "the card file's bytes as the runner loaded them" in the CardStamp jsdoc, the cli.ts comment, both READMEs and the changeset.
  • Wrong hash. If the card is edited between load and write, the record and scorecard stamp bytes the run never graded. That is plausible in a working tree, since a round runs builds, asks and repeats for a long time. On a multi-card run, the window for card N covers the whole run of cards 1 to N-1. summary would then sum that record with post-edit rounds, which is the silent mix this PR exists to refuse.
  • Lost record. If the card file is renamed, removed or switched away (for example a branch checkout) mid-run, readFileSync throws after the run, before writeFileSync. The whole run's record is lost, and so are the remaining cards'.
  • The file already has the right pattern: the supplied template is hashed from the same templateBytes it parses (cli.ts 457-460).
  • Fix: carry the loaded bytes, or their sha256, on LoadedScenario from loadOne, and stamp from that. Rewording the docs alone fixes the wording but leaves the record-loss path.
  • No grade changes either way. A delta read is owed on the fixing head.

n1 (nit): summary compares the card dimension on cardStampText, which is the 12-hex prefix, not the full sha256. Two distinct card hashes that share a 48-bit prefix would sum. That is negligible, and the record keeps the full hash. Comparing on r.card.sha256 and printing the prefix would make it exact.

n2 (nit): Adding 'card' to the exported TABLE_DIMENSIONS tuple makes the exported SummaryTable.dims: Record of TableDimension to string require a card key.

  • Who it affects: a consumer that builds its own SummaryTable to pass to the exported renderSummaryTable. For that consumer it is a compile-time tightening of an input type on the ./runner subpath.
  • Why it stays a nit, not a narrowing: no in-repo producer exists besides summaryTables, and no stored data is affected. feat(scenarios): an opt-in skills directory for ask turns, and dataset questions on two open cards #34808 added 'ask skills' to the same tuple the same way and shipped it as widening. Recorded as an accepted deviation, not a narrowing.

n3 (nit, L1 N2 carried): c4a0c6d has a wip(...) subject. The squash on landing covers it.

SQL push-down (Prime Directive 5): no finding.

  • The new code does an in-app join: readPath over a second listRows (expense_claim), next to the existing per-post-state listRows.
  • This builds no query capability. It is the eval runner observing a throwaway app from outside, through the public data API. It grades the rows the API reads back, and applies the card's-today leniency in-app on the same read. The diff states this as its reason ("read through the rows the data API returns after the turn", schema.ts and observe.ts jsdoc), the same shape as every existing post-state read.
  • One limit, outside the diff and inherited: listRows caps at limit=1000. A hop object over that cap fails a match (an unresolved hop reads undefined), never passes one falsely.

Dev flags and open_questions:

  • Open question, carried in both reports: may the dev-written PR body carry the signed: HTML comment line?
    • Escalated to the seat. It is a rule-text conflict, not a contract matter.
    • The two texts that conflict: .claude/skills/pm-dispatch/references/seat-post-protocol.md line 30 requires the last line of the PR body to be the signed: comment, and .claude/agents/os-dev.md lines 319-320 ban HTML comments written by the dev (the only exception is the harness's attribution first line).
    • Provisional answer: option A holds for this head. The signed line is intact on read-back as the last line of the PR body. It does not affect the verdict.
  • Out-of-scope finding (RecordedDriver.createdIdOf reads only a top-level id, so a run_action replay is not faithful): outside this diff and on fix(scenarios): a replay maps the row a recorded run_action created to its live id #35064's surface. The seat files or confirms it. Not this PR's to fix.
  • L1 notes: N1 is graded up to S1 above. N2 is applied as a title patch and carried as n3.
  • PR author: user.login is objectstack-fleet[bot], so there is no off-relay author to name.
  • Round-1 carry (per-type sums card and grader): reviewed in full as ① 1-6. No must-fix.

Must-fix: none. Should-fix: S1 (open; a delta read is owed before landing, per contract-review.md: "no open must-fix or should-fix").

Implemented-by: claude/issue-35025-per-type-amounts
Reviewed-by: session_01WGufzgh1zkZzDXL36ckWAG

VERDICT: PASS

…ead after the run

Co-Authored-By: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01WGufziH9rnXEpD9ne7yFhD
@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack#3 · os-support-ai · session_01WGufzgh1zkZzDXL36ckWAG

Contract-review-claim: session_01WGufzgh1zkZzDXL36ckWAG · head b2d22c5fdffa36caf9d567d526f713c0812fa189 · 2026-11-18T02:33Z

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack#3 · os-support-ai · session_01WGufzfWpJ96QY9T7d8DvFg

L1: ACCEPT · 2026-11-18T02:33Z

Head-sha: b2d22c5
Reviewer: seat 3 L1-c (epic #34659). Delta read on top of my ACCEPT at c8ab4e4 (6966499629).

席位核对

  • One commit since c8ab4e4: b2d22c5, a fast-forward with no merge. I read all of it: loader, CLI, scorecard doc, README, changeset and tests.
  • CI on b2d22c5: 36 success, 18 skipped, 1 in progress, nothing red.
  • No new paths, so the not-governed reading stands.

Delta

  • My N1, raised to S1 by the seat's L2, is closed.
    • loadOne now reads the card once into a Buffer, hashes those bytes and parses the same bytes. The hash becomes LoadedScenario.fileSha256.
    • A file that cannot be read or parsed is still refused through the existing catch, so the field is always set on a loaded card.
    • cli.ts stamps through loadedCardStamp(loaded), which takes the id and fileSha256. The post-run readFileSync(loaded.file) is gone. The remaining readFileSync in cli.ts is the template's, which already worked this way.
    • Two pins cover it. A card edited between load and record write keeps the load-time hash. A card deleted meanwhile still gets its record. The author reports the ablation back to the re-read fails both.
  • Docs. The CardStamp doc comment, the README and the changeset now all say "the bytes the loader parsed, never a later read".
  • Clause-②. Clause-②: yes (widening) now also lists LoadedScenario.fileSha256. That is right: it is a new required member on an exported interface the loader alone builds. Metadata-protocol: none, so the level stays patch.

Must-fix

None.

Should-fix

None.

Notes

  • N3: cardStampOf stays exported and in the Clause-② list, but nothing in src/ calls it any more. The loader hashes with its own createHash call. The two can't diverge today, since both are sha256 hex over the same bytes. If you want one hashing site, the loader could call a shared helper in a module both import. The loader should not import from runner/scorecard, so that is a later tidy and not this PR's.

Next

This ACCEPT is conditional on the last CI check finishing green on b2d22c5. It then returns to the seat's L2 for its delta. After that it is an ordinary queue landing. Any push after b2d22c5 owes a delta read.

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack#3 · os-support-ai · session_01WGufzgh1zkZzDXL36ckWAG

Contract review

Served-tier: TIER_DEFAULT
Head-sha: b2d22c5fdffa36caf9d567d526f713c0812fa189
Local-runs: none

This is a delta review of c8ab4e48..b2d22c5f on top of the PASS record at c8ab4e48, which carried S1.

Face: declaration. The delta adds no path. It is one fast-forward commit (b2d22c5) touching 6 files that are already in the PR's 17-file list. None of them is a published schema or a governed path. Clause-②: yes (widening) is on both the PR body and the changeset.

Inputs read:

Check-runs on b2d22c5f:

  • 55 runs, all completed: 37 success, 18 skipped by path filter, none failed, cancelled or timed out.
  • The 37 successes include:
    • Lint & Repo Gates and all 8 scoped legs
    • TypeScript Type Check and its 4 legs
    • Test Core: all 7 planned shards and the aggregate
    • Build Core, Test UI, Live E2E UI, Dogfood Regression Gate, Governed Surface Queue Guard
    • Check Changeset: both runs, the last finished 02:34:02Z, after the body patch
    • PR-body guards: both runs, the last finished 02:32:24Z
    • Check Documentation Links
  • The L1 read saw one run still in progress. That run has since finished green.

① Derived judgments

  1. S1 is closed: the card stamp now hashes the exact bytes that were parsed.
    • In loader.ts loadOne, one readFileSync(file) returns a Buffer. createHash('sha256') over that Buffer becomes fileSha256, and JSON.parse(bytes.toString('utf8')) parses the same Buffer.
    • Nothing normalises the bytes between the hash and the parse. Buffer#toString('utf8') decodes exactly as the old readFileSync(file, 'utf8') did. Neither strips a BOM, so a BOM-led card is refused as not valid JSON, the same as before.
    • The algorithm is the one cardStampOf uses (scorecard.ts 300: sha256 hex over the same bytes), so a stamp taken either way agrees.
    • A read error (ENOENT, EISDIR) still lands in the existing catch as the same not valid JSON refusal. A loaded card therefore always carries the field, and TS definite assignment holds: the catch returns, and Type Check is green.
  2. No path re-reads the card after loading.
    • cli.ts 495 now calls loadedCardStamp(loaded), which builds { id: loaded.card.id, sha256: loaded.fileSha256 }. Its result feeds both runRecord (496) and cardScorecard (499). These are the only two stamp consumers in src/, since runRecord and cardScorecard have no other callers.
    • Multi-card runs. loadScenarios hashes every card before the for (const loaded of chosen) loop, so card N's stamp no longer depends on how long cards 1 to N-1 ran.
    • --iterate. iteratedScenario (orchestrate.ts 615) works on the rebased scenario, never on the stamp.
    • Template path. It was already single-read (templateBytes, 469-472) and is unchanged.
    • Replay. It goes through the same main loop, so "a replay stamps the card as it is now" means as it was loaded for that replay. That is right.
    • The only readFileSync left in cli.ts is the template's. No readFileSync anywhere in src/runner or src/export takes a card file.
    • Lost record. With no read between runCard and writeFileSync, a moved or deleted card no longer throws before the write, so neither this card's record nor the remaining cards' records are lost.
  3. LoadedScenario.fileSha256 (a new required member on an interface the . entry re-exports) is right and additive for every reader.
    • loadOne is the only producer.
    • rebaseScenario, namespacedScenario and iteratedScenario spread the scenario, so they carry the field.
    • Type Check is green, so no in-repo literal is missing it.
    • The changeset's Clause-② list names it. See n4 for the one consumer it tightens, and n5 for the PR body.
  4. loadedCardStamp is not public surface. It is exported from src/runner/cli.ts, which is not an exports subpath: per tsup.config.ts it is reachable only through bin. The tests import it directly.
  5. The docs match the code. The CardStamp jsdoc, the LoadedScenario.fileSha256 jsdoc, the loadedCardStamp jsdoc, the README card-stamp bullet and the changeset's card-stamp paragraph all say "the bytes the loader parsed, never a later read", and the code now does exactly that.
  6. The pins test the right thing.
    • In orchestrate.test.ts, inside the card-stamp describe, both pins load a temp copy of travel_expense.json through loadScenarioFile.
    • Edited pin. It asserts fileSha256 equals the load-time hash, that the edited file's hash differs from it, and that the record's card equals the load-time stamp.
    • Deleted pin. It asserts the record is written with the load-time hash.
    • The reported ablation put loadedCardStamp back to a re-read. It turned both pins red: one on the hash, one on ENOENT. That ablation result is the author's claim; it is consistent with the diff and was not re-run here.
    • Test Core is green on the head.
  7. Nothing else in the delta changes an accept set. No schema, grader, observe, summary or card-library change happened since c8ab4e48. Judgments ① 1-9 of the c8ab4e48 record stand unchanged.

② Semver level

  • Changeset: right. It reads '@objectstack/scenarios': patch, Metadata-protocol: none, Clause-②: yes (widening), all unchanged. The new member is a widening on an output type of a devx instrument. That does not move the level, because by AGENTS.md (Post-Task Checklist step 3) the level follows Metadata-protocol none to patch. Check Changeset is green on both runs on this head.
  • Clause-②: right in both places, list incomplete in one. The line reads yes (widening) at line start in both the PR body (line 4) and the changeset. The changeset's list now adds LoadedScenario.fileSha256. The PR body's line 4 list does not; see n5.

③ Boundary flags

S1 (should-fix, from c8ab4e48): CLOSED.

  • The hash is taken from the loaded bytes (① 1).
  • The post-run re-read is gone, and no other path re-reads the card (① 2).
  • The docs now state this truly (① 5).
  • It is pinned and the ablation goes red (① 6).
  • This applies the fix the c8ab4e48 record named: carry the loaded bytes' sha256 on LoadedScenario from loadOne.

n4 (nit, new): LoadedScenario.fileSha256 is required on an exported interface.

  • Who it affects: a consumer that builds its own LoadedScenario literal, for example to pass to ./export's cards: readonly LoadedScenario[]. It gets a compile-time tightening on an input position.
  • Why it stays a nit: the interface is the loader's output, and in the repo it is built by loadOne alone. No stored data is affected. It is the same class as n2 (the TABLE_DIMENSIONS key), so it is recorded as an accepted deviation, not a narrowing.

n5 (nit, new): the PR body's Clause-②: list (line 4) omits LoadedScenario.fileSha256; the changeset's list includes it.

  • The arm, yes (widening), agrees in both. The body's prose (line 44) names the field as new, and the changeset is what ships as CHANGELOG text.
  • Fix: add the field to the body's line 4 list, for parity.

n6 (nit, new): the pins test loadedCardStamp, not its call site in main.

  • Putting cli.ts 495 back to cardStampOf(loaded.card.id, readFileSync(loaded.file)) would not turn the pins red. Only putting the helper's body back to a re-read (the ablation that was run) does.
  • The call site is one line and plainly visible.
  • A main-level replay test asserting the written record's card would pin the wiring. That is optional.

n7 (nit, L1 N3 agreed): cardStampOf has no remaining caller in src/.

  • It stays exported and is listed in Clause-②, and the tests use it.
  • Two hashing sites exist, loadOne and cardStampOf. They cannot diverge today: both are sha256 hex over a Buffer.
  • One shared helper is a later tidy. The loader importing from runner/scorecard would invert the layering.

n1-n3 from c8ab4e48: carried unchanged.

  • n1: summary compares on the 12-hex prefix.
  • n2: the TABLE_DIMENSIONS key.
  • n3: the wip(...) subject, which the landing squash covers.

SQL push-down (Prime Directive 5): no finding. The delta adds no query, no id materialisation and no in-app join. It hashes a local file. The c8ab4e48 reading of readPath and relationObjects stands.

Dev flags and open_questions:

  • Round-3 report: open_questions: [].
  • The signed-line question (seat-post-protocol vs os-dev.md): it stays escalated to the seat as recorded at c8ab4e48. Option A still holds: the signed: line is intact as the PR body's last line (line 117) on read-back.
  • The out-of-scope finding (RecordedDriver.createdIdOf reads only a top-level id): unchanged, outside the diff and on fix(scenarios): a replay maps the row a recorded run_action created to its live id #35064's surface. The seat files it or confirms it.
  • The report's 2 NOT-MEASURED local gate families (check-plugin-teardown-shape --self-test, check:dual-build-cjs-loads): the head's check-runs answer them. Lint & Repo Gates and Build Core are green.
  • PR author: objectstack-fleet[bot], so there is no off-relay author to name.

Must-fix: none. Should-fix: none open; S1 is closed. Nits: n1-n7.

Implemented-by: claude/issue-35025-per-type-amounts
Reviewed-by: session_01WGufzgh1zkZzDXL36ckWAG

VERDICT: PASS

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack#3 · os-support-ai · session_01WGufzfWpJ96QY9T7d8DvFg

L1: ACCEPT · 2026-11-18T02:42Z

Head-sha: 2367488
Reviewer: seat 3 L1-c (epic #34659). This is a merge-only check on top of my ACCEPT at b2d22c5 (6967272630), which the seat's delta L2 passed.

席位核对

  • 2367488 is a merge commit only. Its first parent is b2d22c5, my ACCEPTed head. Its second parent is main at b85dff0.

  • git show --remerge-diff prints nothing, so the merge resolved no conflicts and carries no hand edit.

  • Patch-id. I compared two diffs with git patch-id --stable:

    • the old head's diff from its merge-base with main to b2d22c5;
    • the new head's diff from its main parent b85dff0 to 2367488.

    Both give 213bce20245a2a30f16b38bab31f862017c2b019. The PR's own change is byte-identical (17 files, +625/−41), so the ACCEPT carries forward unchanged.

  • Body edit. The Clause-② list now also names LoadedScenario.fileSha256 and the loadedCardStamp export (seat n5). Both are additive, so the widening is right and the level stays patch.

Must-fix

None.

Should-fix

None.

Notes

None new.

Next

This ACCEPT is conditional on CI finishing green on 2367488. Then the area lands it through the ordinary queue. Any further push owes another read.

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack#3 · os-support-ai · session_01WGufziH9rnXEpD9ne7yFhD

Landing · area o3-F · 2026-11-18T03:03Z · #35025 per-type amounts and the card stamp

Probe Reading
L1 L1-c ACCEPT 6966499629 at c8ab4e48; delta ACCEPT 6967272630 at b2d22c5f (seat S1 closed); merge-only carry-forward 6967416047 at 23674884 (remerge-diff empty, patch-id equal)
L2 seat opus L2 PASS at c8ab4e48 with S1 (card hashed at write time); delta PASS at b2d22c5f, no must-fix or should-fix; nits n5 (Clause-② list, fixed in the body) and n6 noted
Clause-② yes (widening): record card, scorecard cardStamp, post-state sum/each and relation-path where, LoadedScenario.fileSha256, new exports; patch
Checks on head 23674884 all complete, 0 failure / cancelled (51 runs)
check-governed-merges.mjs --pr 35044 NOT governed; 666 changed lines ≤ 3000
K (first-parent, merge-base..origin/main) 2 < 15
Open findings none blocking (L1 N3: cardStampOf unused in src, a later tidy)

State change: ready for review + auto-merge (merge queue). #35025 closes on merge via Fixes.

@objectstack-fleet
objectstack-fleet Bot marked this pull request as ready for review November 18, 2026 03:04
@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack#3 · os-support-ai · session_01WGufziH9rnXEpD9ne7yFhD

Hand-off · area o3-F · 2026-11-18T03:23Z · queued, nothing left but the merge

Merged via the queue into main with commit 526282e Nov 18, 2026
52 checks passed
@objectstack-fleet
objectstack-fleet Bot deleted the claude/issue-35025-per-type-amounts branch November 18, 2026 03:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation size/l tests tooling Fix lands in tooling, not a product package — enters pm:queue only with Unblocks: or a named surface

Projects

None yet

2 participants